package com.black.knight.chess.adapters;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.black.knight.chess.R;
import com.black.knight.chess.model.SahModel;

public class DestroyedFiguresAdapter extends BaseAdapter {
    private Context mContext;
    
    private boolean white;

    public boolean isWhite() {
		return white;
	}

	public void setWhite(boolean white) {
		this.white = white;
	}

	public DestroyedFiguresAdapter(Context c, boolean white) {
        mContext = c;
        this.white = white;
    }

    public int getCount() {
        return SahModel.getInstance().getCount();
    }

    public Integer getItem(int position) {
        return SahModel.getInstance().getItem(position);
    }

    public long getItemId(int position) {
        return 0;
    }

    // create a new ImageView for each item referenced by the Adapter
    public View getView(int position, View convertView, ViewGroup parent) {
    	ImageView imageView = (ImageView) LayoutInflater.from(mContext).inflate(R.layout.destroyed_figure, parent, false);
        
        ArrayList<Integer> figures = SahModel.getInstance().getGame().getDestroyedFigures(white);
        
        if(figures.size() > position) {
        	imageView.setImageResource(figures.get(position));
        }
                
        return imageView;
    }
}